package api

import (
	"api_online/data"
	"api_online/response"
	"net/http"
)

type respStruct struct {
	FileName string `json:"file_name"`
	Desc string `json:"desc"`
}

// 文件遍历
func Index(w http.ResponseWriter, r *http.Request) {
	var resp []*respStruct
	cache := data.Cache.GetSyntaxFileList()
	for _, line := range cache {
		resp = append(resp, &respStruct{
			FileName: line.FileName,
			Desc: line.Desc,
		})
	}
	res, _ := response.SuccessRes(resp)
	_, _ = w.Write(res)
}

